local Object = class("Object")
local GameUtils = require("utils.GameUtils")

function Object:ctor(resource)
    local prefabPath = resource.path .. "/" .. resource.name
    local object = G_ResourceManager:loadPrefabs(prefabPath)
    local gameObject = GameUtils.instantiate(object, resource.parent)
    local luaBehaviour = gameObject:GetComponent(typeof(CS.LuaBehaviour))
    if luaBehaviour then
        local scriptEnv = luaBehaviour:GetScriptEnv()
        assert(scriptEnv == nil, "load gameobject by Uibase scriptEnv must nil")
        luaBehaviour:SetScriptEnv(self)
    else
        assert(false, "can not load gameobject by Uibase the LuaBehaviour not found")
    end
end

function Object:delete()
    self:onDelete()
    GameUtils.destroy(self.gameObject)
end

function Object:onDelete()
end

function Object:onDestroy()
end

return Object
